
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <assert.h>
#include <unistd.h>

using namespace std;

#include "RBTree.h"
#include "Map.h"
#include "Set.h"

//void testRBTree1()
//{
//    RBTree<int, int> t1;
//    vector<int> v1 = { 99,55,33,77,1,3,6,2,8,9,45,76,12,87,1,98,23,675,12,76,23,66,23,98,56,87,333,666,999 };
//    for (size_t i = 0; i < v1.size(); i ++ )
//    {
//        t1.insert(make_pair(v1[i], i));
//        cout << "insert" << ':' << v1[i] << '-' << i << endl;
//        cout << "isBalance" << ':' << t1.isRBTree() << endl;
//    }
//
//    t1.InOrder();
//    cout << "isBalance" << ':' << t1.isRBTree() << endl;
//}
//
//void testRBTree2()
//{
//    RBTree<int, int> t1;
//    srand(time(0));
//    int N = 10000;
//    for (int i = 0; i < N; i++)
//    {
//        int x = rand();
//        t1.insert(make_pair(x, i));
//        cout << x << ':' << i << endl;
//        cout << "isBalance" << ':' << t1.isRBTree() << endl;
//    }
//    t1.InOrder();
//    cout << "isBalance" << ':' << t1.isRBTree() << endl;
//}

void testMyset()
{
    my_set::set<int> s1;
    s1.insert(10);
    s1.insert(5);
    s1.insert(1);
    s1.insert(6);
    s1.insert(8);
    s1.insert(2);
    s1.insert(4);
    s1.insert(9);
    s1.insert(7);
    my_set::set<int>::iterator it1 = s1.begin();
    while (it1 != s1.end())
    {
        cout << *it1 << ' ';
        ++ it1;
    }
    cout << endl;
}

void testMymap()
{
    my_map::map<string, int> m1;

    string s[] = { "苹果","香蕉","苹果","西瓜","香蕉","草莓" };
    for (auto& e : s)
    {
        m1[e] ++ ;
    }

    my_map::map<string, int>::iterator it = m1.begin();
    while (it != m1.end())
    {
        cout << it->first << ':' << it->second << endl;
        ++ it;
    }
    cout << endl;
}

int main()
{
    //testRBTree1();
    //testRBTree2();

    testMyset();
    cout << endl;
    testMymap();

    return 0;
}
